package com.ip.oss;

import com.alibaba.fastjson.JSON;
import com.aliyun.oss.OSS;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.ByteArrayInputStream;

@Component
@Log
public class OssClientImpl implements IOssClient {

    @Autowired
    AlOssConfig alOssConfig;
    @Autowired
    OSS ossClient;
/*

    @PostConstruct
    void init() {
        List<Bucket> bucketList = ossClient.listBuckets();
        System.out.println("=============="+bucketList);
    }
*/

    @Override
    public void uploadFile(byte[] file, String dir, String fileName) {
        System.out.println(dir+""+fileName);
//        PutObjectRequest putObjectRequest = new PutObjectRequest(alOssConfig.getBucketName(), dir + fileName, new ByteArrayInputStream(file));
//        PutObjectResult res = ossClient.putObject(putObjectRequest);
        //https://zuoda-real.oss-cn-hangzhou.aliyuncs.com/oss/20250801/08dbc6e8-61b5-4b63-9ae8-e1273f5a2b20.png
     //   http://47.110.38.89/oss/20250801/08dbc6e8-61b5-4b63-9ae8-e1273f5a2b20.png

    }
}
